/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "PORTEFEUILLE_ACTION", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PortefeuilleAction.findAll", query = "SELECT p FROM PortefeuilleAction p"),
    @NamedQuery(name = "PortefeuilleAction.findByNumAction", query = "SELECT p FROM PortefeuilleAction p WHERE p.portefeuilleActionPK.numAction = :numAction"),
    @NamedQuery(name = "PortefeuilleAction.findByNumPort", query = "SELECT p FROM PortefeuilleAction p WHERE p.portefeuilleActionPK.numPort = :numPort"),
    @NamedQuery(name = "PortefeuilleAction.findByDateEntree", query = "SELECT p FROM PortefeuilleAction p WHERE p.dateEntree = :dateEntree"),
    @NamedQuery(name = "PortefeuilleAction.findByDateSortie", query = "SELECT p FROM PortefeuilleAction p WHERE p.dateSortie = :dateSortie")})
public class PortefeuilleAction implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PortefeuilleActionPK portefeuilleActionPK;
    @Column(name = "DATE_ENTREE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateEntree;
    @Column(name = "DATE_SORTIE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateSortie;
    @JoinColumn(name = "NUM_PORT", referencedColumnName = "NUM_PORT", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Portefeuille portefeuille;
    @JoinColumn(name = "NUM_ACTION", referencedColumnName = "NUM_ACTION", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Action action;

    public PortefeuilleAction() {
    }

    public PortefeuilleAction(PortefeuilleActionPK portefeuilleActionPK) {
        this.portefeuilleActionPK = portefeuilleActionPK;
    }

    public PortefeuilleAction(long numAction, int numPort) {
        this.portefeuilleActionPK = new PortefeuilleActionPK(numAction, numPort);
    }

    public PortefeuilleActionPK getPortefeuilleActionPK() {
        return portefeuilleActionPK;
    }

    public void setPortefeuilleActionPK(PortefeuilleActionPK portefeuilleActionPK) {
        this.portefeuilleActionPK = portefeuilleActionPK;
    }

    public Date getDateEntree() {
        return dateEntree;
    }

    public void setDateEntree(Date dateEntree) {
        this.dateEntree = dateEntree;
    }

    public Date getDateSortie() {
        return dateSortie;
    }

    public void setDateSortie(Date dateSortie) {
        this.dateSortie = dateSortie;
    }

    public Portefeuille getPortefeuille() {
        return portefeuille;
    }

    public void setPortefeuille(Portefeuille portefeuille) {
        this.portefeuille = portefeuille;
    }

    public Action getAction() {
        return action;
    }

    public void setAction(Action action) {
        this.action = action;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (portefeuilleActionPK != null ? portefeuilleActionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PortefeuilleAction)) {
            return false;
        }
        PortefeuilleAction other = (PortefeuilleAction) object;
        if ((this.portefeuilleActionPK == null && other.portefeuilleActionPK != null) || (this.portefeuilleActionPK != null && !this.portefeuilleActionPK.equals(other.portefeuilleActionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.PortefeuilleAction[ portefeuilleActionPK=" + portefeuilleActionPK + " ]";
    }
    
}
